{include "Public/header"}
<div class="container-fluid">
  <div class="row-fluid">
    <div class="span12">
      <div class="widget-box">
        <div class="widget-title"> <span class="icon"> <i class="icon-align-justify"></i> </span>
          <h5>{$title}</h5>
        </div>
        <div class="widget-content nopadding">
          <form action="" method="post" class="form-horizontal">
          {if isset($info)}
          <input type="hidden" name="id" value="{$info['id']}" />
          {/if}
            <div class="control-group">
              <label class="control-label">Name</label>
              <div class="controls">
                <input type="text" maxlength="20" name="name" class="span11" value="{$info['name']|''}" placeholder="please input the name" />
              </div>
            </div>
            <div class="control-group">
              <label class="control-label">Power</label>
              <div class="controls">
              	<p>
                	<input type="checkbox" id="menuAll" class="checkbox"/>check all
                </p>
                {foreach $menuList as $v}
					<p>
					<span class="left"><strong>{$v['name']}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong></span>
						{foreach $v['children'] as $item}
							<span class="left"><input type="checkbox" {if isset($item['is_open'])}checked disabled{else}name="menu_id[]" value="{$item['id']}" {/if} {if isset($roleMenuList)&&in_array($item['id'],$roleMenuList)}checked{/if}  />&nbsp;</span>
							<span class="left">{$item['name']}</span>
						{/foreach}
					</p>
					<div class="clear"></div>
					{/foreach}
              </div>
            </div>
            <div class="form-actions">
              <input type="submit" class="btn btn-success" value="save">
            </div>
          </form>
        </div>
      </div>
     </div>
</div></div>
{include "Public/footer"}
<script>
$(function(){
	$("form").validate({
		rules:{
			name:{
				required:true,
				rangelength:[2,20]
			}
		},
		messages:{
			name:{
				required:"name is required",
				rangelength:"The length must be between 2-20"
			}
		}
	});
	$("#menuAll").click(function(){
		if($(this).attr("checked")){
			$("input[name='menu_id[]']").attr("checked",true);
		}else{
			$("input[name='menu_id[]']").attr("checked",false);
		}
	});
});
</script>